
package com.example.new1;


import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.TextView;

public class ProgramInfoActivity extends Activity {
	
	public static String program_name = null; 
	private TextView title, gym, place, target, time, enter, intro;

	private DatabaseAdapter DB ; 
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    requestWindowFeature(Window.FEATURE_NO_TITLE);
	    setContentView(R.layout.program_info);
	    
	    // connect Database 
	    DB = new DatabaseAdapter(this);
		DB.open();
	    
	   
	    title = (TextView)findViewById(R.id.textView3);
	    gym = (TextView)findViewById(R.id.textView7);
	    place = (TextView)findViewById(R.id.textView8);
	    target = (TextView)findViewById(R.id.textView9);
	    time = (TextView)findViewById(R.id.textView10);
	    enter = (TextView)findViewById (R.id.textView13);
	    intro = (TextView)findViewById(R.id.textView11);
	    
	    gym.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View arg0) 
			{
				Intent program_info = (new Intent(ProgramInfoActivity.this, InformationActivity.class));
				startActivity(program_info);
			}
	    	
	    });
	    
	    setData();
	    
	   
	}

	private void setData()
	{
		
		title.setText(program_name);
		Cursor result = DB.getProgramInfo(program_name);
		
		gym.setText(result.getString(0));
		place.setText(result.getString(1));
		target.setText(result.getString(2));
		time.setText(result.getString(3)+"\r\n"+result.getString(4));
		enter.setText(result.getString(5)+"\r\n"+result.getString(6));
		intro.setText(result.getString(7));
		
	}
}

